package com.example.admin.service;


import com.example.admin.common.Result;
import com.example.admin.entity.ElderChildrenInfo;
import com.example.admin.mapper.ElderChildrenMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ElderChildrenService {



    @Autowired
    ElderChildrenMapper elderChildrenMapper;
    public List<ElderChildrenInfo> getElderChildrenPage() {

        List<ElderChildrenInfo> elderChildrenInfoList=elderChildrenMapper.getElderChildrenPage();
        return elderChildrenInfoList;
    }

    public Result deleteElderChirdenById(Integer id) {

       int count= elderChildrenMapper.deleteElderChirdenById(id);
       if(count==0)
       {
           return Result.error("400","删除失败");
       }
       return Result.success("删除成功");
    }

    public Result addElderChirden(ElderChildrenInfo elderChildrenInfo) {
        int count=elderChildrenMapper.addElderChirden(elderChildrenInfo);
        if(count==0)
        {
            return Result.error("400","增加失败");
        }
        return Result.success("增加成功");
    }

    public Result editeElderChildren(ElderChildrenInfo elderChildrenInfo) {

        int count=elderChildrenMapper.editeElderChildren(elderChildrenInfo);
        if(count==0)
        {
            return Result.error("400","修改失败");
        }
        return Result.success("修改成功");
    }

    public List<ElderChildrenInfo> selectElderChilrdrenByName(Integer elderId) {

       List<ElderChildrenInfo> elderChildrenInfoList= elderChildrenMapper.selectElderChilrdrenByName(elderId);
       return elderChildrenInfoList;
    }
}
